simulation results/get_plots.R

library(tidyverse); theme_set(theme_minimal(28))

get_plots <- function(data, type = c("coverage", "width")) {
  if(type == "coverage") {
    data %>%
      map_dfr(~ coverage_p(.x, TRUE)) %>%
      select(-`k=0.4`, -`k=0.5`) %>%
      mutate(
        `k=0.45` = case_when(
          (N <= 150) ~ `k=0.45`
        ),
        `k=0.55` = case_when(
          (N >= 150 & N<= 400) ~ `k=0.55`
        ),
        `k=0.6` = case_when(
          (N >= 400) ~ `k=0.6`
        )
      ) %>%
      rename(ILR = IL) %>%
      select(-p) %>%
      gather("Interval", "Coverage", -N) %>%
      ggplot(aes(N, Coverage)) +
      geom_line(aes(linetype = Interval)) +
      geom_hline(yintercept = 0.95, linetype = "dotted") +
      scale_linetype_manual(
        values = c(
          "ILR" = "twodash",
          "k=0.45" = "solid",
          "k=0.55" = "solid",
          "k=0.6" = "solid",
          "mW" = "dashed"
        )
      )
  } else if(type == "width") {
    data %>%
      map_dfr(~ width_p(.x, TRUE)) %>%
      select(-`k=0.4`, -`k=0.5`) %>%
      mutate(
        `k=0.45` = case_when(
          (N <= 150) ~ `k=0.45`
        ),
        `k=0.55` = case_when(
          (N >= 150 & N<= 400) ~ `k=0.55`
        ),
        `k=0.6` = case_when(
          (N >= 400) ~ `k=0.6`
        )
      ) %>%
      rename(ILR = IL) %>%
      select(-p) %>%
      gather("Interval", "Width", -N) %>%
      ggplot(aes(N, Width)) +
      geom_line(aes(linetype = Interval)) +
      scale_linetype_manual(
        values = c(
          "ILR" = "twodash",
          "k=0.45" = "solid",
          "k=0.55" = "solid",
          "k=0.6" = "solid",
          "mW" = "dashed"
        )
      )
  }
}

get_plots(n_results_p10, "coverage")
get_plots(n_results_p10, "width")
get_plots(n_results_p30, "coverage")
get_plots(n_results_p30, "width")
get_plots(n_results_p50, "coverage")
get_plots(n_results_p50, "width")
BriceonWiley/IntegratedLikelihood.R documentation built on Aug. 21, 2020, 11 p.m.